// 订单模型
const { Orders } = require('../../../models/order');
// 统一数据返回类
const { DataReturn } = require('../../../common/returnclass');

/**
 * @api {Get} /orders/order_number 订单号查询订单
 * @apiGroup Admin-Orders
 *
 * @apiParam {String} order_number 订单编号
 *
 * @apiSuccess {ObjectId} id 订单id
 * @apiSuccess {String} contact  联系人
 * @apiSuccess {Boolean} is_evaluate  是否评价
 * @apiSuccess {Array} estimate  评价
 * @apiSuccess {Boolean} is_pay  是否支付
 * @apiSuccess {Boolean} is_send  是否发货
 * @apiSuccess {String} order_belong  订单所属用户
 * @apiSuccess {String} mobile  联系方式
 * @apiSuccess {String} order_goods  订单所属商品
 * @apiSuccess {String} order_number  订单编号
 * @apiSuccess {String} order_price  订单价格
 * @apiSuccess {String} order_store  订单所属店铺
 * @apiSuccess {String} order_time  订单时间
 * @apiSuccess {String} orders  订单商品
 * @apiSuccess {Array} receiving_address  收货地址
 * @apiSuccess {String} remark  备注
 * @apiSuccess {Array} send_address  发货地址
 * @apiSuccess {Boolean} state  订单状态 0 待付款，1 待发货 2 待收货 3 待评价 4已评价
 */
module.exports = async (req, res) => {
	console.log(req.query);
	// 订单号
	let { order_number } = req.query;
	// 根据订单号查询订单信息
	let orders = await Orders.findOne({ order_number });
	// 查询为空返回
	if (!orders) return DataReturn.getData(res, 200, [], '暂无数据');
	// 响应
	return DataReturn.getData(res, 200, { data:orders }, '查询成功')

}
